package acwing.模拟;

import java.util.Scanner;

/**
 * 移动距离
 *
 * @author yang
 * @date 2021/11/26
 */
public class 移动距离 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt(), m = sc.nextInt(), n = sc.nextInt();
        // 让数组从零开始
        m--;
        n--;
        // 获取行和列
        int x1 = m / w, x2 = n / w;
        int y1 = m % w, y2 = n % w;
        // 翻转
        if (x1 % 2 == 1) y1 = w - 1 - y1;
        if (x2 % 2 == 1) y2 = w - 1 - y2;
        // 计算
        System.out.println(Math.abs(x1 - x2) + Math.abs(y1 - y2));
    }
}
